package tech.dx.springdb.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.dx.springdb.entity.Student;
import tech.dx.springdb.respository.StudentRepository;
import tech.dx.springdb.service.StudentService;

/**
 * @ClassName StudentServiceImpl
 * @Description TODO
 * @Author daoxuan
 * @Date 2019/4/1 11:10
 * @Version 1.0
 */
@Service
public class StudentServiceImpl implements StudentService {


    @Autowired
    private StudentRepository studentRepository;

    @Override
    public Student add(Student student) {
        return studentRepository.save(student);
    }

    @Override
    public Student update(Student student) {
        return studentRepository.save(student);
    }

    @Override
    public Student getById(long id) {
        return studentRepository.findById(id).get();
    }
}
